package com.atguigu.ct.web.controller;

import com.atguigu.ct.web.bean.Calllog;
import com.atguigu.ct.web.service.CalllogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * Description: 通话日志的控制器对象
 * @Author: yyx
 * @Create: 2023/5/8 23:26
 * @Version: 8
 */
@Controller
public class CalllogController {
    @Autowired
    private CalllogService calllogService;

    @RequestMapping("/query")
    public String query(){
        return "query";
    }

   /* @ResponseBody
    @RequestMapping("/view")
    // Object ==> json ==> String
    public Object view(){
        Map<String,String> dataMap = new HashMap<String,String>();
        dataMap.put("username","张三");
        dataMap.put("age","20");
        return dataMap;
    }*/

    @RequestMapping("/view")
    public String view(String tel , String calltime, Model model){
        //查询统计结果
        List<Calllog> calllogs = calllogService.queryMonthDatas(tel,calltime);
        model.addAttribute("calllogs",calllogs);
        return "view";
    }
}
